//SSAOMapFX.h
//Created 06/08/13
//Created By Daniel Bowler
//
//An effect that will aid us generating an SSAO map. The effect will take the
//view space normal depth input and generate a SSAO map ready to be handed to the blur
//effect.

#pragma once

#include "AbstractFX.h"

class SSAOMapFX : public AbstractFX
{
	//Shader manager will create an instance of this fx, like all other effects
	friend ShaderManager;
public:
	//Per vertex struct.
	struct SSAOMapVertex
	{
		XMFLOAT3 PosL;
		XMFLOAT2 Tex;
		float    FarPlaneIndex;
	};

	//Set data.
	void SetCBufferPerFrame(CXMMATRIX viewToTexSpaceMatrix, 
		XMFLOAT4 *offset, XMFLOAT4 *corners);

	void SetShaderResources(ID3D11ShaderResourceView* viewspaceNormalDepth,
		ID3D11ShaderResourceView* randomVectorMap);

private:
	//Constructor/Desturcotr
	SSAOMapFX(ID3D11Device* device);
	~SSAOMapFX();
	//Disable assignment operator and copy constrcutor.
	SSAOMapFX(SSAOMapFX& other);
	SSAOMapFX& operator=(SSAOMapFX& other);

	//Override the init methods.
	void InitInputLayout(ID3D11Device* device);
	void InitShaderVariablePointers();

private:
	//Shader variables/textures/cbuffers etc.
	ID3DX11EffectMatrixVariable* viewTexVar;
	ID3DX11EffectVectorVariable* offsetVectorArrVar;
	ID3DX11EffectVectorVariable* frustumCornerArrVar;

	//SRV
	ID3DX11EffectShaderResourceVariable* viewspaceNormalDepthMapVar;
	ID3DX11EffectShaderResourceVariable* randomVectorMapVar;
};